package com.itheima.project.feign;

import com.itheima.project.basic.ResponseWrap;
import com.itheima.project.hystrix.FileHystrix;
import com.itheima.project.vo.file.FileVo;
import com.itheima.project.vo.file.UploadMultipartFile;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName FileFeign.java
 * @Description 附件feign接口
 */
@FeignClient(value = "module-file-web",fallback = FileHystrix.class)
public interface FileFeign {

    /***
     * @description 文件下载
     * @param fileId 上传对象
     * @return: com.itheima.travel.req.FileVo
     */
    @PostMapping("file/down-load/{fileId}")
    ResponseWrap<FileVo> downLoad(@PathVariable("fileId") Long fileId);

    /***
     * @description 文件上传--服务远程调用
     * @param file 上传对象
     * @return: com.itheima.travel.req.FileVo
     */
    @PostMapping("file/up-load/feign")
    ResponseWrap<FileVo> upLoad(@RequestBody UploadMultipartFile file,
                                @RequestParam("businessType") String  businessType,
                                @RequestParam("enterpriseId") String  enterpriseId);

    /***
     * @description 业务绑定单个附件【路径传递参数方式】
     * @param fileId    附件ID
     * @param businessId 业务ID
     * @return
     */
    @PostMapping("file/bind-business-id/{fileId}/{businessId}")
    public ResponseWrap<List<FileVo>> bindBusinessId(
            @PathVariable("fileId") Long fileId,
            @PathVariable("businessId")  Long businessId);

    /**
     * @Description 为上传绑定对应的业务Id
     * @param  fileVo 附件对象
     * @return com.itheima.travel.req.FileVo
     */
    @PostMapping("file/bind-business-id")
    ResponseWrap<List<FileVo>> bindBusinessId(FileVo fileVo);

    /**
     * @Description 移除业务原图片，并绑定新的图片到业务上
     * @param  fileVo 附件对象
     * @return
     */
    @PostMapping(value = "file/replace-bind-business-id")
    ResponseWrap<Boolean> replaceBindBusinessId(FileVo fileVo);

    /**
     * @Description 移除业务原图片，并批量绑定新的图片到业务上
     * @param  fileVos 附件对象
     * @return
     */
    @PostMapping(value = "file/replace-bind-batch-business-id")
    ResponseWrap<Boolean> replaceBindBatchBusinessId(@RequestBody ArrayList<FileVo> fileVos);

    /**
     * @Description 相同业务绑定多个附件
     * @param  fileVos 相同业务的多个附件对象
     * @return
     */
    @PostMapping("file/bind-batch-business-id")
    ResponseWrap<List<FileVo>> bindBatchBusinessId(@RequestBody ArrayList<FileVo> fileVos);

    /**
     * @Description 按业务ID查询附件【对象传递参数方式】
     * @param  fileVo 附件对象
     * @return com.itheima.travel.req.FileVo
     */
    @PostMapping("file/select-by-businessId")
    ResponseWrap<List<FileVo>> findFileVoByBusinessId(FileVo fileVo);

    /**
     * @Description 按业务ID查询附件【路径传递参数方式】
     * @return com.itheima.travel.req.FileVo
     */
    @PostMapping("file/select-by-businessId/{businessId}")
    public ResponseWrap<List<FileVo>> findFileVoByBusinessId(@PathVariable("businessId") Long businessId);

    /**
     * @Description 删除业务相关附件
     * @param fileVo 附件对象
     * @return
     */
    @DeleteMapping("file/delete-by-businessId")
    ResponseWrap<Boolean> deleteFileVoByBusinessId(FileVo fileVo);

}
